<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api',
    'middleware' => ['serializer:array', 'bindings'],
], function ($api) {
    // 登录
    $api->post('authorizations', 'AuthorizationsController@store')
        ->name('api.authorizations.store');
    // 刷新 token
    $api->put('authorizations/current', 'AuthorizationsController@update')
        ->name('api.authorizations.update');
    // 删除 token
    $api->delete('authorizations/current', 'AuthorizationsController@destory')
        ->name('api.authorizations.destory');

    $api->post('talent/upload', 'TalentController@upload');

    $api->group(['middleware' => 'api.auth'], function ($api) {
        // 当前登录用户信息
        $api->get('user', 'UsersController@me')
            ->name('api.user.me');
        // 首页信息
        $api->get('dashboard', 'DashboardController@index');

        // 学校
        $api->get('university', 'UniversityController@index');
        $api->post('university', 'UniversityController@store');
        $api->patch('university/{university}', 'UniversityController@update');
        $api->delete('university/{university}', 'UniversityController@delete');
        // 部门
        $api->get('department', 'DepartmentController@index');
        $api->get('department/{department}', 'DepartmentController@show');
        $api->post('department', 'DepartmentController@store');
        $api->patch('department/{department}', 'DepartmentController@update');
        $api->delete('department/{department}', 'DepartmentController@delete');
        // 项目
        $api->get('project', 'ProjectController@index');
        $api->post('project', 'ProjectController@store');
        $api->patch('project/{project}', 'ProjectController@update');
        $api->delete('project/{project}', 'ProjectController@delete');
        $api->get('project_all', 'ProjectController@all');
        // 职位
        $api->get('job', 'JobController@index');
        $api->post('job', 'JobController@store');
        $api->patch('job/{job}', 'JobController@update');
        $api->delete('job/{job}', 'JobController@delete');
        // 人才
        $api->get('talent', 'TalentController@index');
        $api->get('talent_special', 'TalentController@special');
        $api->post('talent', 'TalentController@store');
        $api->get('talent/download_template', 'TalentController@download_template');
        $api->patch('talent/{talent}', 'TalentController@update');
        $api->delete('talent/{talent}', 'TalentController@delete');
        $api->patch('talent/send_waiting_interview/{talent}', 'TalentController@send_waiting');
        $api->patch('talent/send_waiting_interview2/{talent}', 'TalentController@send_waiting2');
        $api->patch('talent/send_first_interview/{talent}', 'TalentController@send_first');
        $api->patch('talent/send_second_interview/{talent}', 'TalentController@send_second');
        $api->patch('talent/send_hr_interview/{talent}', 'TalentController@send_hr');
        $api->post('talent/mul_waiting_interview', 'TalentController@mul_waiting');
        $api->post('talent/upload_resume', 'TalentController@upload_resume');
        // 面试管理-待面试
        $api->get('interview/waiting', 'InterviewController@waiting');
        $api->get('interview/waiting_second', 'InterviewController@waiting_second');
        $api->get('interview/waiting_hr', 'InterviewController@waiting_hr');
        $api->get('interview/waiting_quick', 'InterviewController@waiting_quick');
        $api->patch('interview/waiting/update/{talent}', 'InterviewController@waiting_update');
        $api->patch('interview/waiting/back_pool/{talent}', 'InterviewController@back_pool'); // 丢弃到人才库
        // 面试管理-一面
        $api->get('interview/first', 'InterviewController@first');
        $api->patch('interview/first/update/{talent}', 'InterviewController@first_comment');
        // 面试管理-二面
        $api->get('interview/second', 'InterviewController@second');
        $api->patch('interview/second/update/{talent}', 'InterviewController@second_comment');
        // 面试管理-HR终面
        $api->get('interview/hr', 'InterviewController@hr');
        $api->get('interview/hr_a', 'InterviewController@hr_a');
        $api->get('interview/hr_b', 'InterviewController@hr_b');
        $api->get('interview/hr_c', 'InterviewController@hr_c');
        $api->get('interview/success', 'InterviewController@offer_success');
        $api->patch('interview/hr/update/{talent}', 'InterviewController@hr_comment');
        $api->patch('interview/hr_a/update/{talent}', 'InterviewController@hr_a_comment');
        $api->patch('interview/hr_b/update/{talent}', 'InterviewController@hr_b_comment');
        $api->patch('interview/hr_c/update/{talent}', 'InterviewController@hr_c_comment');
        // 面试批次管理
        $api->get('batch', 'BatchController@index');
        $api->get('batch/search_name', 'BatchController@searchByName');
        $api->get('batch/{batch}', 'BatchController@show');
        $api->patch('batch/tiaoji', 'BatchController@tiaoji');
        $api->get('batch/tiaoji_list/{batch}', 'BatchController@tiaoji_list');
        $api->get('batch/interview-list/{batch}', 'BatchController@interviewList');
        $api->patch('batch/change_interviewer/{batch}', 'BatchController@change_interviewer');

        // 系统设置
        $api->get('setting/account', 'AccountController@index');
        $api->post('setting/account', 'AccountController@store');
        $api->get('setting/account/{user}', 'AccountController@show');
        $api->patch('setting/account/{user}', 'AccountController@update');
        $api->delete('setting/account/{user}', 'AccountController@destroy');

        $api->get('setting/roles', 'RolesController@index');
        $api->post('setting/add_roles', 'RolesController@add');

        $api->get('user_search', 'UsersController@searchByName');
    });

    $api->get('talent/export_index', 'TalentController@export_index');
    $api->get('talent/export_special', 'TalentController@export_special');
    $api->get('interview/export_waiting', 'InterviewController@export_waiting');
    $api->get('interview/export_first', 'InterviewController@export_first');
    $api->get('interview/export_waiting_second', 'InterviewController@export_waiting_second');
    $api->get('interview/export_second', 'InterviewController@export_second');
    $api->get('interview/export_waiting_hr', 'InterviewController@export_waiting_hr');
});
